package com.atguigu.singleton.type1;

/**
 * 静态常量 类装载的时候就实例化了，没有懒加载
 */
public class SingletonTest01 {

	public static void main(String[] args) {
		Singleton instance = Singleton.getInstance();
		Singleton instance2 = Singleton.getInstance();
		System.out.println(instance == instance2); // true
		System.out.println("instance.hashCode=" + instance.hashCode());
		System.out.println("instance2.hashCode=" + instance2.hashCode());
	}

}


class Singleton {

	private Singleton() {
		
	}
	
	private final static Singleton instance = new Singleton();
	
	public static Singleton getInstance() {
		return instance;
	}
	
}